Delete
Delete
@DeleteMapping("/students/{studenId}")
public String delete(@PathVariable Integer studenId) {
String sql = "DELETE FROM student WHERE id = :studentId";
Map<String, Object> map = new HashMap<>();
map.put("studentId", studenId);
int result = namedParameterJdbcTemplate.update(sql, map);
// 回傳值為影響的行數
if (result >= 1) {
return "delete success! " + "delete id:" + studenId;
}else {
return "delete fail! the id may not exist!";
}}